<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>银行贷款筛选器 - 上下布局版</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --primary: #38b2ac;       /* 清新的蓝绿色 */
            --primary-light: #76d7d1; /* 浅蓝绿色 */
            --primary-dark: #319795;  /* 深蓝绿色 */
            --secondary: #63b3ed;    /* 柔和的蓝色 */
            --accent: #9ae6b4;       /* 清新的薄荷绿 */
            --success: #48bb78;      /* 清新的绿色 */
            --warning: #ed8936;      /* 柔和的橙色 */
            --danger: #e53e3e;       /* 柔和的红色 */
            --light: #f7fafc;        /* 非常浅的蓝色 */
            --dark: #2d3748;         /* 深蓝灰色 */
            --gray: #a0aec0;         /* 中灰色 */
            --border: #e2e8f0;       /* 浅灰色边框 */
            --card-bg: #ffffff;      /* 卡片背景白色 */
            --text-primary: #2d3748; /* 主要文本颜色 */
            --text-secondary: #718096; /* 次要文本颜色 */
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background-color: #f1f5f9;
            color: var(--dark);
            line-height: 1.6;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        
        header {
            text-align: center;
            margin-bottom: 20px;
            padding: 20px 0;
            background: linear-gradient(135deg, var(--primary), var(--primary-dark));
            color: white;
            border-radius: 10px;
            box-shadow: var(--card-shadow);
        }
        
        header h1 {
            font-size: 2.5rem;
            margin-bottom: 10px;
        }
        
        header p {
            font-size: 1.1rem;
            opacity: 0.9;
            max-width: 700px;
            margin: 0 auto;
        }
        
        .app-container {
            display: flex;
            flex-direction: column;
            gap: 25px;
        }
        
        .input-section {
            background: white;
            border-radius: 10px;
            padding: 24px;
            overflow: hidden;

            &.is-collapsed {
                height: 96px;

                .section-header {
                    border-bottom: none;
                }
            }
        }
        
        .results-section {
            background: white;
            border-radius: 10px;
            padding: 24px;
            flex-grow: 1;
        }

        .section-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 2px solid var(--border);
        }

        .section-title {
            font-size: 1.5rem;
            color: var(--primary-dark);
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .toggle-btn {
            background: var(--primary);
            color: white;
            border: none;
            padding: 8px 15px;
            border-radius: 6px;
            font-size: 0.9rem;
            cursor: pointer;
            transition: background 0.3s;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .toggle-btn:hover {
            background: var(--primary-dark);
        }
        
        .form-container {
            display: flex;
            flex-direction: column;
            gap: 24px;
        }
        
        .form-group {
            border-bottom: 1px solid var(--border);
            padding-bottom: 24px;
        }

        .form-group-content {
            display: flex;
            gap: 16px;
            flex-wrap: wrap;

            >div {
                flex: 1;
            }

            .form-item {
                min-width: 200px;
            }
        }

        .form-group h3 {
            font-size: 1.2rem;
            margin-bottom: 15px;
            color: var(--secondary);
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
        }
        
        input, select {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid var(--border);
            border-radius: 6px;
            font-size: 1rem;
            transition: border-color 0.3s;
        }
        
        input:focus, select:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        }
        
        .checkbox-group input {
            width: auto;
            margin-right: 10px;
        }
        
        .btn {
            background: var(--primary);
            color: white;
            border: none;
            padding: 14px 25px;
            border-radius: 6px;
            font-size: 1.1rem;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.3s;
            display: block;
            width: 100%;
            text-align: center;
        }
        
        .btn:hover {
            background: var(--primary-dark);
        }
        
        .results-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }
        
        .results-count {
            font-size: 1.1rem;
            color: var(--secondary);
        }
        
        .sort-filter {
            display: flex;
            gap: 10px;
            margin-bottom: 24px;
        }
        
        .sort-filter select {
            width: auto;
            padding: 8px 12px;
        }
        
        .no-results {
            text-align: center;
            padding: 40px 20px;
            color: var(--secondary);
        }
        
        .no-results i {
            font-size: 3rem;
            margin-bottom: 20px;
            color: var(--gray);
        }
        
        .no-results h3 {
            font-size: 1.5rem;
            margin-bottom: 10px;
        }
        
        .match-percentage {
            display: inline-block;
            background: var(--success);
            color: white;
            padding: 3px 10px;
            border-radius: 20px;
            font-size: 0.9rem;
            font-weight: 600;
        }
        
        .toggle-details {
            background: none;
            border: none;
            color: var(--primary);
            cursor: pointer;
            font-size: 0.9rem;
            padding: 5px 0;
            display: flex;
            align-items: center;
            gap: 5px;
        }
        
        /* 列表样式 */
        
        .bank-table th {
            background-color: #f1f5f9;
            padding: 12px 15px;
            text-align: left;
            font-weight: 600;
            color: var(--secondary);
            border-bottom: 2px solid var(--border);
            position: sticky;
            top: 0;
        }
        
        .bank-table td {
            padding: 12px 15px;
            border-bottom: 1px solid var(--border);
        }
        
        .bank-table tr:nth-child(even) {
            background-color: #f8fafc;
        }
        
        .bank-table tr:hover {
            background-color: #eef6ff;
        }
        
        .bank-name {
            font-weight: 600;
            color: var(--primary-dark);
        }
        
        .match-details-list {
            list-style-type: none;
            padding: 0;
            margin-top: 10px;
        }
        
        .match-details-list li {
            margin-bottom: 8px;
            display: flex;
            align-items: flex-start;
            font-size: 0.9rem;
        }
        
        .match-details-list li:before {
            content: "✓";
            color: var(--success);
            font-weight: bold;
            margin-right: 10px;
        }
        
        .detail-label {
            font-size: 0.9rem;
            color: var(--gray);
            margin-bottom: 5px;
        }
        
        .detail-value {
            font-weight: 600;
        }
        
        .expand-icon {
            transition: transform 0.3s;
        }
        
        .expanded .expand-icon {
            transform: rotate(180deg);
        }
        
        .input-controls {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 16px;

            button {
                flex: 1;
            }
        }
        
        .reset-btn {
            background: var(--secondary);
        }
        
        .reset-btn:hover {
            background: #374151;
        }
        
        .results-container {
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 10px;
        }

        /* 使用 div 的网格列表样式，替代 table */
        .bank-list {
            width: 100%;
            margin-top: 20px;
        }

        .bank-header,
        .bank-row {
            display: grid;
            grid-template-columns: 1.2fr 1.4fr 1fr 1fr 1fr 1.2fr 1fr 0.8fr 0.6fr;
            align-items: center;
            gap: 12px;
            padding: 12px 10px;
            border-bottom: 1px solid var(--border);
        }

        .bank-header {
            background-color: #f1f5f9;
            position: sticky;
            top: 0;
            z-index: 1;
            font-weight: 600;
            color: var(--secondary);
        }

        .bank-row:nth-child(even) {
            background-color: #f8fafc;
        }

        .bank-row:hover {
            background-color: #eef6ff;
        }

        .bank-row .cell {
            min-width: 0; /* 避免溢出 */
        }

        .bank-row .details {
            grid-column: 1 / -1;
            padding: 12px;
            background: #f8fafc;
            border-radius: 8px;
            margin-top: 8px;
        }

        /* 修正展开图标旋转 */
        .expand-icon {
            transition: transform 0.3s;
        }
        .expand-icon.expanded {
            transform: rotate(180deg);
        }

        /* 响应式：窄屏下改为卡片布局（简化显示） */
        @media (max-width: 900px) {
            .bank-header {
                display: none;
            }
            .bank-row {
                grid-template-columns: 1.2fr 1fr 1fr 0.8fr;
                grid-auto-rows: auto;
                gap: 8px 12px;
            }
            .bank-row .cell:nth-child(1) { grid-column: 1 / 3; }
            .bank-row .cell:nth-child(2) { grid-column: 3 / 5; }
            .bank-row .cell:nth-child(3) { grid-column: 1 / 2; }
            .bank-row .cell:nth-child(4) { grid-column: 2 / 3; }
            .bank-row .cell:nth-child(5) { grid-column: 3 / 4; }
            .bank-row .cell:nth-child(6) { grid-column: 4 / 5; }
            .bank-row .cell:nth-child(7) { grid-column: 1 / 3; }
            .bank-row .cell:nth-child(8) { grid-column: 3 / 4; }
            .bank-row .cell:nth-child(9) { grid-column: 4 / 5; justify-self: end; }
            .bank-row .details { grid-column: 1 / -1; }
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="container">
            <header>
                <h1><i class="fas fa-university"></i> 银行贷款筛选器</h1>
                <p>根据您的个人条件，智能匹配最适合的银行贷款产品</p>
            </header>
            
            <div class="app-container">
                <!-- 输入区域 -->
                <section class="input-section" :class="{ 'is-collapsed': isFilterPanelCollapsed}">
                    <div class="section-header">
                        <h2 class="section-title"><i class="fas fa-edit"></i> 输入您的条件</h2>
                        <button class="toggle-btn" @click="isFilterPanelCollapsed = !isFilterPanelCollapsed">
                            <i :class="isFilterPanelCollapsed ? 'fas fa-chevron-down' : 'fas fa-chevron-up'"></i>
                            {{ isFilterPanelCollapsed ? '展开筛选条件' : '收起筛选条件' }}
                        </button>
                    </div>
                    
                    <div class="form-container">
                        <div class="form-group">
                            <h3><i class="fas fa-user"></i> 基本信息</h3>

                            <div class="form-group-content">
                                <div class="form-item">
                                    <label for="age">年龄</label>
                                    <input type="number" id="age" min="18" max="70" v-model.number="userInput.age">
                                </div>

                                <div class="form-item">
                                    <label for="employerType">单位类型</label>
                                    <select id="employerType" v-model="userInput.employerType">
                                        <option value="公务员/事业单位">公务员/事业单位</option>
                                        <option value="国企/央企">国企/央企</option>
                                        <option value="上市公司/500强">上市公司/500强</option>
                                        <option value="民营企业">民营企业</option>
                                        <option value="其他">其他</option>
                                    </select>
                                </div>


                                <div class="form-item">
                                    <label for="workDuration">本单位工作时长（月）</label>
                                    <input type="number" id="workDuration" min="0" max="600" v-model.number="userInput.workDuration">
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <h3><i class="fas fa-money-bill-wave"></i> 收入与资产</h3>

                            <div class="form-group-content">
                                <div class="form-item">
                                    <label for="monthlyIncome">月收入（元）</label>
                                    <input type="number" id="monthlyIncome" min="0" v-model.number="userInput.monthlyIncome">
                                </div>

                                <div class="form-item">
                                    <label for="annualIncome">年收入（元）</label>
                                    <input type="number" id="annualIncome" min="0" v-model.number="userInput.annualIncome">
                                </div>

                                <div class="form-item">
                                    <label for="hasMortgage">是否有按揭房</label>
                                    <select id="hasMortgage" v-model="userInput.hasMortgage">
                                        <option :value="0">否</option>
                                        <option :value="1">是</option>
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <h3><i class="fas fa-home"></i> 公积金/社保</h3>

                            <div class="form-group-content">
                                <div class="form-item">
                                    <label for="fundDuration">公积金缴存时长（月）</label>
                                    <input type="number" id="fundDuration" min="0" max="600" v-model.number="userInput.fundDuration">
                                </div>

                                <div class="form-item">
                                    <label for="fundBase">公积金月缴存基数（元）</label>
                                    <input type="number" id="fundBase" min="0" v-model.number="userInput.fundBase">
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <h3><i class="fas fa-file-invoice"></i> 征信状况</h3>

                            <div class="form-group-content">
                                <div class="form-item">
                                    <label for="currentOverdue">是否有当前逾期</label>
                                    <select id="currentOverdue" v-model="userInput.currentOverdue">
                                        <option value="no">否</option>
                                        <option value="yes">是</option>
                                    </select>
                                </div>

                                <div class="form-item">
                                    <label for="continuousOverdue">近两年连续逾期次数</label>
                                    <input type="number" id="continuousOverdue" min="0" v-model.number="userInput.continuousOverdue">
                                </div>

                                <div class="form-item">
                                    <label for="totalOverdue">近两年累计逾期次数</label>
                                    <input type="number" id="totalOverdue" min="0" v-model.number="userInput.totalOverdue">
                                </div>

                                <div class="form-item">
                                    <label for="queries2m">近两个月查询次数</label>
                                    <input type="number" id="queries2m" min="0" v-model.number="userInput.queries2m">
                                </div>

                                <div class="form-item">
                                    <label for="queries6m">近六个月查询次数</label>
                                    <input type="number" id="queries6m" min="0" v-model.number="userInput.queries6m">
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <h3><i class="fas fa-chart-line"></i> 负债情况</h3>

                            <div class="form-group-content">
                                <div class="form-item">
                                    <label for="totalDebt">总负债金额（元）</label>
                                    <input type="number" id="totalDebt" min="0" v-model.number="userInput.totalDebt">
                                </div>
                                <div class="form-item">
                                    <label for="loanCount">信用贷款机构数</label>
                                    <input type="number" id="loanCount" min="0" v-model.number="userInput.loanCount">
                                </div>

                                <div class="form-item">
                                    <label for="microLoanCount">小贷/网贷笔数</label>
                                    <input type="number" id="microLoanCount" min="0" v-model.number="userInput.microLoanCount">
                                </div>

                                <div class="form-item">
                                    <label for="creditCardUsage">信用卡使用率（%）</label>
                                    <input type="number" id="creditCardUsage" min="0" max="100" v-model.number="userInput.creditCardUsage">
                                </div>
                            </div>
                        </div>

                        <div class="input-controls">
                            <button class="btn reset-btn" @click="resetForm">
                                <i class="fas fa-redo"></i> 重置条件
                            </button>
                            <button class="btn" @click="filterBanks">
                                <i class="fas fa-search"></i> 筛选可贷款银行
                            </button>
                        </div>
                    </div>
                </section>
                
                <!-- 结果区域 -->
                <section class="results-section">
                    <div class="results-header">
                        <h2 class="section-title"><i class="fas fa-list"></i> 筛选结果</h2>
                        <div class="results-count">找到 {{ matchedBanks.length }} 家银行</div>
                    </div>
                    
                    <div class="sort-filter">
                        <select v-model="sortBy">
                            <option value="match">匹配度优先</option>
                            <option value="rate">利率最低优先</option>
                            <option value="amount">额度最高优先</option>
                        </select>
                        <select v-model="filterMethod">
                            <option value="all">全部申请方式</option>
                            <option value="online">仅线上申请</option>
                        </select>
                    </div>
                    
                    <div class="results-container">
                        <div v-if="matchedBanks.length === 0" class="no-results">
                            <i class="fas fa-search"></i>
                            <h3>暂无匹配的银行</h3>
                            <p>请填写上方表单并点击"筛选可贷款银行"按钮</p>
                        </div>
                        
                        <div v-else class="bank-list">
                            <div class="bank-header">
                                <div class="cell">银行</div>
                                <div class="cell">产品</div>
                                <div class="cell">额度</div>
                                <div class="cell">利率</div>
                                <div class="cell">期限</div>
                                <div class="cell">还款方式</div>
                                <div class="cell">申请方式</div>
                                <div class="cell">匹配度</div>
                                <div class="cell">详情</div>
                            </div>

                            <div class="bank-row" v-for="bank in sortedBanks" :key="bank.id">
                                <div class="cell"><div class="bank-name">{{ bank.name }}</div></div>
                                <div class="cell">{{ bank.product }}</div>
                                <div class="cell">{{ bank.maxAmount }}</div>
                                <div class="cell">{{ bank.minRate }}</div>
                                <div class="cell">{{ bank.term }}</div>
                                <div class="cell">{{ bank.repayment }}</div>
                                <div class="cell">{{ bank.applyMethod }}</div>
                                <div class="cell"><span class="match-percentage">{{ calculateMatchPercentage(bank, userInput) }}%</span></div>
                                <div class="cell">
                                    <button class="toggle-details" @click="toggleDetails(bank.id)">
                                        <i class="fas fa-chevron-down expand-icon" :class="{ 'expanded': expandedBankId === bank.id }"></i>
                                    </button>
                                </div>

                                <div class="details" v-show="expandedBankId === bank.id">
                                    <div class="match-details">
                                        <div class="match-title">匹配条件：</div>
                                        <ul class="match-details-list">
                                            <li v-for="(reason, index) in calculateMatchReasons(bank, userInput)" :key="index">{{ reason }}</li>
                                        </ul>

                                        <div class="bank-details" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 15px; margin-top: 15px;">
                                            <div class="detail-item">
                                                <span class="detail-label">最高额度</span>
                                                <span class="detail-value">{{ bank.maxAmount }}</span>
                                            </div>
                                            <div class="detail-item">
                                                <span class="detail-label">最低年化利率</span>
                                                <span class="detail-value">{{ bank.minRate }}</span>
                                            </div>
                                            <div class="detail-item">
                                                <span class="detail-label">最长期限</span>
                                                <span class="detail-value">{{ bank.term }}</span>
                                            </div>
                                            <div class="detail-item">
                                                <span class="detail-label">还款方式</span>
                                                <span class="detail-value">{{ bank.repayment }}</span>
                                            </div>
                                            <div class="detail-item">
                                                <span class="detail-label">申请方式</span>
                                                <span class="detail-value">{{ bank.applyMethod }}</span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>
            </div>
        </div>
    </div>

    <script>
        new Vue({
            el: '#app',
            data: {
                // 银行数据
                banks: [
                    {
                        id: 1,
                        name: "农业银行",
                        product: "一网捷贷",
                        maxAmount: "30万",
                        minRate: "3.6%",
                        term: "3年",
                        repayment: "等额本息/先息后本",
                        applyMethod: "线上",
                        requirements: {
                            employerType: ["公务员/事业单位", "国企/央企"],
                            fundDuration: 24,
                            currentOverdue: "no",
                            continuousOverdue: 0,
                            totalOverdue: 4,
                            queries2m: 5,
                            queries6m: 12,
                            totalDebt: 500000,
                            loanCount: 4,
                            microLoanCount: 2
                        }
                    },
                    {
                        id: 2,
                        name: "工商银行",
                        product: "融E借",
                        maxAmount: "100万",
                        minRate: "3.7%",
                        term: "5年",
                        repayment: "等额本息/先息后本",
                        applyMethod: "线上/线下",
                        requirements: {
                            fundDuration: 12,
                            currentOverdue: "no",
                            queries2m: 4,
                            queries6m: 10,
                            totalDebt: 300000,
                            microLoanCount: 3
                        }
                    },
                    {
                        id: 3,
                        name: "中国银行",
                        product: "随心智贷",
                        maxAmount: "50万",
                        minRate: "3.8%",
                        term: "3年",
                        repayment: "等额本息",
                        applyMethod: "线上",
                        requirements: {
                            fundDuration: 6,
                            currentOverdue: "no",
                            continuousOverdue: 0,
                            totalOverdue: 1,
                            microLoanCount: 3,
                            loanCount: 3
                        }
                    },
                    {
                        id: 4,
                        name: "建设银行",
                        product: "建易贷",
                        maxAmount: "50万",
                        minRate: "3.9%",
                        term: "3年",
                        repayment: "等额本息/先息后本",
                        applyMethod: "线上",
                        requirements: {
                            employerType: ["公务员/事业单位", "国企/央企", "上市公司/500强"],
                            fundDuration: 12,
                            currentOverdue: "no",
                            queries2m: 4,
                            queries6m: 10,
                            loanCount: 6
                        }
                    },
                    {
                        id: 5,
                        name: "浦发银行",
                        product: "浦闪贷",
                        maxAmount: "50万",
                        minRate: "3.4%",
                        term: "3年",
                        repayment: "等额本息/先息后本",
                        applyMethod: "线上",
                        requirements: {
                            employerType: ["公务员/事业单位", "国企/央企", "上市公司/500强"],
                            fundDuration: 12,
                            currentOverdue: "no",
                            queries2m: 3,
                            queries6m: 10,
                            totalDebt: 1000000,
                            microLoanCount: 2
                        }
                    },
                    {
                        id: 6,
                        name: "中信银行",
                        product: "信秒贷",
                        maxAmount: "30万",
                        minRate: "4.2%",
                        term: "1年",
                        repayment: "等额本息",
                        applyMethod: "线上",
                        requirements: {
                            fundDuration: 24,
                            currentOverdue: "no",
                            queries2m: 4,
                            queries6m: 10,
                            totalDebt: 1000000,
                            microLoanCount: 4
                        }
                    },
                    {
                        id: 7,
                        name: "招商银行",
                        product: "闪电贷",
                        maxAmount: "50万",
                        minRate: "4.0%",
                        term: "3年",
                        repayment: "等额本息/先息后本",
                        applyMethod: "线上",
                        requirements: {
                            fundDuration: 12,
                            currentOverdue: "no",
                            queries2m: 6,
                            queries6m: 15,
                            totalDebt: 800000,
                            microLoanCount: 3
                        }
                    },
                    {
                        id: 8,
                        name: "交通银行",
                        product: "惠民贷",
                        maxAmount: "30万",
                        minRate: "3.9%",
                        term: "3年",
                        repayment: "等额本息",
                        applyMethod: "线上",
                        requirements: {
                            employerType: ["公务员/事业单位", "国企/央企"],
                            fundDuration: 12,
                            currentOverdue: "no",
                            queries2m: 4,
                            queries6m: 12,
                            totalDebt: 500000,
                            microLoanCount: 2
                        }
                    }
                ],
                
                // 用户输入数据
                userInput: {
                    age: 35,
                    employerType: "公务员/事业单位",
                    workDuration: 36,
                    monthlyIncome: 15000,
                    annualIncome: 180000,
                    hasMortgage: 1,
                    fundDuration: 36,
                    fundBase: 12000,
                    currentOverdue: "no",
                    continuousOverdue: 0,
                    totalOverdue: 2,
                    queries2m: 3,
                    queries6m: 8,
                    totalDebt: 300000,
                    loanCount: 2,
                    microLoanCount: 1,
                    creditCardUsage: 60
                },
                
                // 筛选结果
                matchedBanks: [],
                
                // 排序和过滤选项
                sortBy: "match",
                filterMethod: "all",
                
                // 展开详情状态
                expandedBankId: null,

                isFilterPanelCollapsed: false,
            },
            computed: {
                // 排序后的银行列表
                sortedBanks() {
                    let banks = [...this.matchedBanks];
                    
                    // 应用申请方式过滤
                    if (this.filterMethod === "online") {
                        banks = banks.filter(bank => bank.applyMethod.includes("线上"));
                    }
                    
                    // 应用排序
                    if (this.sortBy === "rate") {
                        return banks.sort((a, b) => {
                            const rateA = parseFloat(a.minRate);
                            const rateB = parseFloat(b.minRate);
                            return rateA - rateB;
                        });
                    } else if (this.sortBy === "amount") {
                        return banks.sort((a, b) => {
                            const amountA = parseFloat(a.maxAmount);
                            const amountB = parseFloat(b.maxAmount);
                            return amountB - amountA;
                        });
                    } else {
                        // 默认按匹配度排序
                        return banks.sort((a, b) => {
                            const matchA = this.calculateMatchPercentage(a, this.userInput);
                            const matchB = this.calculateMatchPercentage(b, this.userInput);
                            return matchB - matchA;
                        });
                    }
                }
            },
            methods: {
                // 筛选银行
                filterBanks() {
                    this.matchedBanks = this.banks.filter(bank => {
                        const req = bank.requirements;
                        const user = this.userInput;
                        
                        // 检查单位类型
                        if (req.employerType && !req.employerType.includes(user.employerType)) {
                            return false;
                        }
                        
                        // 检查公积金时长
                        if (req.fundDuration && user.fundDuration < req.fundDuration) {
                            return false;
                        }
                        
                        // 检查当前逾期
                        if (req.currentOverdue && user.currentOverdue !== req.currentOverdue) {
                            return false;
                        }
                        
                        // 检查连续逾期
                        if (req.continuousOverdue !== undefined && user.continuousOverdue > req.continuousOverdue) {
                            return false;
                        }
                        
                        // 检查累计逾期
                        if (req.totalOverdue !== undefined && user.totalOverdue > req.totalOverdue) {
                            return false;
                        }
                        
                        // 检查近2个月查询次数
                        if (req.queries2m !== undefined && user.queries2m > req.queries2m) {
                            return false;
                        }
                        
                        // 检查近6个月查询次数
                        if (req.queries6m !== undefined && user.queries6m > req.queries6m) {
                            return false;
                        }
                        
                        // 检查总负债
                        if (req.totalDebt !== undefined && user.totalDebt > req.totalDebt) {
                            return false;
                        }
                        
                        // 检查贷款笔数
                        if (req.loanCount !== undefined && user.loanCount > req.loanCount) {
                            return false;
                        }
                        
                        // 检查小贷/网贷笔数
                        return !(req.microLoanCount !== undefined && user.microLoanCount > req.microLoanCount);
                    });
                    
                    // 重置展开状态
                    this.expandedBankId = null;
                },
                
                // 计算匹配原因
                calculateMatchReasons(bank, userInput) {
                    const req = bank.requirements;
                    const reasons = [];
                    
                    // 单位类型匹配
                    if (req.employerType && req.employerType.includes(userInput.employerType)) {
                        reasons.push(`单位类型符合要求（${userInput.employerType}）`);
                    }
                    
                    // 公积金时长匹配
                    if (req.fundDuration && userInput.fundDuration >= req.fundDuration) {
                        reasons.push(`公积金缴存时长符合要求（≥${req.fundDuration}个月）`);
                    }
                    
                    // 逾期情况匹配
                    if (req.currentOverdue && userInput.currentOverdue === req.currentOverdue) {
                        reasons.push(`无当前逾期记录`);
                    }
                    
                    if (req.continuousOverdue !== undefined && userInput.continuousOverdue <= req.continuousOverdue) {
                        reasons.push(`连续逾期次数符合要求（≤${req.continuousOverdue}次）`);
                    }
                    
                    if (req.totalOverdue !== undefined && userInput.totalOverdue <= req.totalOverdue) {
                        reasons.push(`累计逾期次数符合要求（≤${req.totalOverdue}次）`);
                    }
                    
                    // 查询次数匹配
                    if (req.queries2m !== undefined && userInput.queries2m <= req.queries2m) {
                        reasons.push(`近2个月查询次数符合要求（≤${req.queries2m}次）`);
                    }
                    
                    if (req.queries6m !== undefined && userInput.queries6m <= req.queries6m) {
                        reasons.push(`近6个月查询次数符合要求（≤${req.queries6m}次）`);
                    }
                    
                    // 负债情况匹配
                    if (req.totalDebt !== undefined && userInput.totalDebt <= req.totalDebt) {
                        reasons.push(`总负债金额符合要求（≤${this.formatNumber(req.totalDebt)}元）`);
                    }
                    
                    // 贷款笔数匹配
                    if (req.loanCount !== undefined && userInput.loanCount <= req.loanCount) {
                        reasons.push(`信用贷款机构数符合要求（≤${req.loanCount}家）`);
                    }
                    
                    if (req.microLoanCount !== undefined && userInput.microLoanCount <= req.microLoanCount) {
                        reasons.push(`小贷/网贷笔数符合要求（≤${req.microLoanCount}笔）`);
                    }
                    
                    return reasons;
                },
                
                // 计算匹配百分比
                calculateMatchPercentage(bank, userInput) {
                    const reasons = this.calculateMatchReasons(bank, userInput);
                    return Math.min(100, Math.floor((reasons.length / 10) * 100));
                },
                
                // 数字格式化函数
                formatNumber(num) {
                    return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
                },
                
                // 切换详情展开状态
                toggleDetails(bankId) {
                    if (this.expandedBankId === bankId) {
                        this.expandedBankId = null;
                    } else {
                        this.expandedBankId = bankId;
                    }
                },
                
                // 重置表单
                resetForm() {
                    this.userInput = {
                        age: 35,
                        employerType: "公务员/事业单位",
                        workDuration: 36,
                        monthlyIncome: 15000,
                        annualIncome: 180000,
                        hasMortgage: 1,
                        fundDuration: 36,
                        fundBase: 12000,
                        currentOverdue: "no",
                        continuousOverdue: 0,
                        totalOverdue: 2,
                        queries2m: 3,
                        queries6m: 8,
                        totalDebt: 300000,
                        loanCount: 2,
                        microLoanCount: 1,
                        creditCardUsage: 60
                    };
                    this.filterBanks();
                }
            },
            mounted() {
                // 初始化时执行一次筛选
                this.filterBanks();
            }
        });
    </script>
</body>
</html>